package com.cnsoft.portal.saas.app;

import java.util.List;

import org.cnsoft.framework.beans.MyBeanFactoryHelper;
import org.cnsoft.framework.beans.common.RESTResultBean;
import org.cnsoft.framework.beans.user.UserBean;
import org.cnsoft.framework.cache.session.SessionHelper;
import org.cnsoft.framework.support.MyPageControllerSupport;
import org.cnsoft.framework.utils.DateHelper;
import org.cnsoft.persistent.common.ManagerMenu.ManagerMenuDBO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.cnsoft.persistent.company2.C212010CompanyApplyService.C212010CompanyApplyServiceDBO;
import com.cnsoft.portal.home.ISManagerHomeService;

/**
 * 通用App管理页面
 * 
 * @author ZmSoft
 * @version 0.1.0 2018/3/1
 * @since 0.1.0 2018/3/1
 */
@Controller
// @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@RequestMapping(value = "/pc/1.0/saas/communal/app")
public class PageSaasCommunalAppHomeController extends MyPageControllerSupport {
		
	
	// 管理后台首页-主题页面
	@RequestMapping(value = "/main.do", method = RequestMethod.POST)
	public ModelAndView doAppMainPOST(C212010CompanyApplyServiceDBO param) throws Exception {
		logger.debug("C212010CompanyApplyServiceDBO.param=====>>>>" + param.toJsonString());
		ModelAndView modelAndView = getModelAndView("/saas-app/saas-app-main");
		modelAndView.addObject("service", param);
		
		// 基础信息
		UserBean currentUser = SessionHelper.currentUser();
		modelAndView.addObject("DDD", DateHelper.currentTimeMillis2());
		modelAndView.addObject("token", SessionHelper.currentToken());
		modelAndView.addObject("loginer", currentUser);

		return modelAndView; // 返回result对象给前端
	}
	
	// 管理后台首页-右侧列表数据
	@RequestMapping(value = "/center.do", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView doAppCenterPOST(C212010CompanyApplyServiceDBO param,String token) throws Exception {
		logger.debug("C212010CompanyApplyServiceDBO.param=====>>>>" + param.toJsonString());
		ModelAndView modelAndView = getModelAndView("/saas-app/saas-app-center");
		modelAndView.addObject("service", param);
		
		// 基础信息
		UserBean currentUser = SessionHelper.currentUser();
		modelAndView.addObject("DDD", DateHelper.currentTimeMillis2());
		modelAndView.addObject("token", token);
		modelAndView.addObject("loginer", currentUser);

		return modelAndView; // 返回result对象给前端
	}

	// 管理后台首页
	@RequestMapping(value = "/menu.do", method = RequestMethod.POST)
	public ModelAndView doAppMenuPOST(ManagerMenuDBO param) throws Exception {
		logger.debug("ManagerMenuDBO.param=====>>>>" + param.toJsonString());
		ModelAndView modelAndView = getModelAndView("/saas-app/saas-app-menu");
		// 用户菜单
		ISManagerHomeService _ManagerHomeService_ = MyBeanFactoryHelper.getBean(ISManagerHomeService.class);
		RESTResultBean<List<ManagerMenuDBO>> result = _ManagerHomeService_.doUserMenu(param);
		modelAndView.addObject("MENU", result.getData());
		// 基础信息
		UserBean currentUser = SessionHelper.currentUser();
		modelAndView.addObject("DDD", DateHelper.currentTimeMillis2());
		modelAndView.addObject("token", SessionHelper.currentToken());
		modelAndView.addObject("loginer", currentUser);

		return modelAndView; // 返回result对象给前端
	}
}
